<?php

/**
 * 
 * @author yuxun
 *
 */
class SynchroInfoService extends Service{
	
	public static function getSynchroInfo($classify,$classify_id,$status = true){
		$modSynchroInfo = new ModSynchroInfo();
		$params = array();
		$params['classify'] = $classify;
		$params['classify_id'] = $classify_id;
		if($status == true){
			$params['status'] = 1;
		}
		$list = $modSynchroInfo->select($params);
		return $list;
	}
	
	public static function get($id){
		$modSynchroInfo = new ModSynchroInfo();
		$obj = $modSynchroInfo->findByPk($id);
		
		if($obj){
			$info = $obj->getAttributes();
			return $info;
		}else{
			return false;
		}
	
	}
	
	
	
	public static function getServerIden($server_array_ids,$classify,$classify_iden){
		$modSynchroInfo = new ModSynchroInfo();
		$serverIden = $modSynchroInfo->getServerIden($server_array_ids,$classify,$classify_iden);
		
		$result = array();
		foreach ($serverIden as $key=>$val){
			$end_time = $val['start_time'] + ($val['duration'] - 1) * 60 * 60 * 24;
			$d_end_time = date('Y-m-d 23:59:59', $end_time);
			$end_time = strtotime($d_end_time);
			$now_time = time();
			if($now_time < $end_time && $val['is_open'] == 0){  //还没有结束的 且 开启的
				$result[$val['server_id']] = $val['classify_iden'];
			}
		}
		
		return $result;
		
	}
	
	

}